/*
 * MathLib.h
 * -contains math objects useful for raytracing 
 *
 * @version 	1.00 Feb 2011
 * @author 		Eric Stock
 */



#ifndef __MATH_LIB
#define __MATH_LIB

#define flt float

namespace math
{ 
	class Vector;
	class Vertex;
	
	class Matrix
	{
		public:

		Matrix() {
			for(int i=0; i<16; i++) {
				cell[i] = 0;            
			}        
		}

		math::Vertex TransformVert(Vertex &v); 
		flt& operator() (int element) { return cell[element]; }
		flt& operator[](int i) { return cell[i]; }
		Matrix operator*(const Matrix& matIn);
		flt cell[16];
	};


	class Vertex
	{
    public:
        Vertex() { data[0] = 0.0; data[1] = 0.0; data[2] = 0.0; }       
		Vertex(flt x, flt y, flt z) { data[0] = x; data[1] = y; data[2] = z; }
		flt data[3];
		Vertex & operator+=(const math::Vector& p_Vector);
		const Vertex operator+(const math::Vector& p_Vector) const;
		flt& operator[](int i) { return data[i]; }
	}; 

	class Vector
	{
    public:
		Vector()  { data[0] = 0.0; data[1] = 0.0; data[2] = 0.0; }                             
		Vector(flt x, flt y, flt z) { data[0] = x; data[1] = y; data[2] = z; }
		flt data[3];           
        void Normalize();
		flt Length();
		math::Vector & operator*=(const flt p_dist);
		const math::Vector operator*(const flt p_dist) const;
        flt& operator[](int i) { return data[i]; }
		const flt& operator[](int i) const { return data[i]; }

		static Vector Cross(Vector &p_Vector1, Vector &p_Vector2);
	};   
}

#endif